package com.qzsoft.zhjd.materiel.modules.materielitem.entity;

import java.util.Date;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.qzsoft.jeemis.common.validator.group.AddGroup;
import com.qzsoft.jeemis.common.validator.group.UpdateGroup;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @ClassName MaterielItemEntity
 * @Description 材料字典数据对象
 * @author linhuawei
 * @since 2022-03-29
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
@TableName("n_materiel_item")
public class MaterielItemEntity {
    /**
     * 主键
     */
    @NotBlank(groups = UpdateGroup.class, message = "材料标识不可为空")
    @TableId(type = IdType.ASSIGN_UUID)
    private String pkid;

    /**
     * 上级主键
     */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String ppkid;

    /**
     * 唯一标识
     */
    private String id;

    /**
     * 材料名称
     */
    @NotNull(groups = { AddGroup.class, UpdateGroup.class }, message = "材料名称不可为空")
    @Length(groups = { AddGroup.class, UpdateGroup.class }, max = 20, message = "材料名称不可超过{max}字")
    private String name;

    /**
     * 材料编码
     */
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String code;

    /**
     * 规格
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String spec;

    /**
     * 计量单位
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String unit;

    /**
     * 备注
     */
    @Length(groups = { AddGroup.class, UpdateGroup.class }, max = 200, message = "备注信息不可超过{max}字")
    private String remark;

    /**
     * 是否是类别：0否，1是
     */
    @NotNull(groups = { AddGroup.class, UpdateGroup.class }, message = "是否类别不可为空")
    @Range(groups = { AddGroup.class, UpdateGroup.class }, min = 0, max = 1, message = "是否类别错误")
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private Integer category;

    /**
     * 是否需要过磅：0否，1是
     */
    @NotNull(groups = { AddGroup.class, UpdateGroup.class }, message = "是否需要过磅不可为空")
    private Integer weighed;

    /**
     * 添加人主键
     */
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    private Long creator;

    /**
     * 添加时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date createDate;

    /**
     * 最后修改人主键
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updater;

    /**
     * 最后修改时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateDate;

}
